<?php 
    if(!isset($_SESSION['user']) || !isset($_SESSION['Adimn']))
    {
        session_start(); // php functions file
    }
require_once('./inc/database.php');
require_once('./inc/functions.php');
require_once('./class/class.user.php');
require_once('./class/class.project.php');
require_once('./class/class.task.php');

?>




<input id="hid_session" name="hid_session" type="hidden" value="<?php echo $_SESSION['user'] ?>" />

<div id="slidebar" class="slideright ui-widget" >
    <div id="search_project"> 
        <input name="find_project" id="find_project" type="text" onfocus="if(this.value=='חיפוש פרויקט...'){this.value=''}" onblur="if(this.value==''){ this.value='חיפוש פרויקט...'}" value="חיפוש פרויקט..."   />
        <input name="find_bnt" id="find_bnt" type="button"  value="" />
        
        <div id="search_autocomplete"></div>
    </div>



	<div id="project_scroll"> 
         <div id="project" class="scroll-pane"> 
          <?php $a=new user();
                 $arr_pro= array();
                $a->getby_name($_SESSION['user']);
                if($a->role_type==1 || $a->role_type==6 )
                {
                  $arr=project::getallproject();	
                }
                else 
                {
                $arr=$a->get_proj_permissions();
                }
                
                foreach($arr as $i)
                    {
                        $temp =new project();
                        $bool=$temp->getby_id($i);
                       if ($bool)
                        {
							if( $a->role_type==1 || $a->role_type==6)
							 {  
                               echo '<p id="slide_project" class="my_permissions" onclick="show_project('.$temp->getid().')">'.$temp->project_name.'</P>';
                               array_push($arr_pro,$temp);					
							 }
							else 
							 { 
								if($temp->project_status!=1)
								 {
									 echo '<p id="slide_project" class="my_permissions" onclick="show_project('.$temp->getid().')">'.$temp->project_name.'</P>';
                                     array_push($arr_pro,$temp); 
								 }
							 }
                        }
                        else {echo "error";} 
						
                    }
				if($a->role_type==2 || $a->role_type==3)
					{
						$t=$a->get_proj_unpermissions();
						
						foreach($t as $i)
                      { 
                        $temp =new project();
                        $bool=$temp->getby_id($i);
                       
					    if ($bool)
                        {   
						 if($temp->project_status!=1)
						  {
                            echo '<p id="slide_project" class="my_unpermissions" onclick="show_project('.$temp->getid().')">'.$temp->project_name.'</P>';
                            array_push($arr_pro,$temp);					
						  }
                        }
                        else{echo "error";echo "$i";} 
                    }
						
					}
                    
           ?>
          
         </div><!-- # project--> 
     </div><!-- # project_scroll--> 
</div><!-- # sidebar--> 


<style>
#project_scroll{
	margin:0 auto;
	width:210px;	
}
#project{
	float:right;
	width:100%;
	height:430px;	
	margin-top:30px;
}
.my_unpermissions{
	float:right;
	margin-right:20px;
	margin-top:10px;
	width:185px;
	min-height:30px;
	border:1px solid #626262;
	-webkit-box-shadow: inset 0px 0px 5px 1px rgba(96, 147, 149, 0.5);
	-moz-box-shadow: inset 0px 0px 5px 1px rgba(96, 147, 149, 0.5);
	box-shadow: inset 0px 0px 5px 1px rgba(96, 147, 149, 0.5);
	background:#fff;
	text-align:center;
	line-height:30px;
}
.my_unpermissions:hover{
	border:1px solid #609395;
	-webkit-box-shadow: inset 0px 0px 7px 3px rgba(96, 147, 149, 0.5);
	-moz-box-shadow: inset 0px 0px 7px 3px rgba(96, 147, 149, 0.5);
	box-shadow: inset 0px 0px 7px 3px rgba(96, 147, 149, 0.5); 
}

.my_permissions{
	float:right;
	margin-right:20px;
	margin-top:10px;
	width:185px;
	min-height:30px;
	border:1px solid #626262;
	-webkit-box-shadow: inset 0px 0px 5px 6px rgba(96, 147, 149, 0.5);
	-moz-box-shadow: inset 0px 0px  5px 6px rgba(96, 147, 149, 0.5);
	box-shadow: inset 0px 0px  5px 6px rgba(96, 147, 149, 0.5);
	background:#fff;
	text-align:center;
	line-height:30px;
	
}
.my_permissions:hover{
	border:1px solid #609395;
	-webkit-box-shadow: inset 0px 0px 6px 7px rgba(96, 147, 149, 0.5);
	-moz-box-shadow: inset 0px 0px 6px 7px rgba(96, 147, 149, 0.5);
	box-shadow: inset 0px 0px 6px 7px rgba(96, 147, 149, 0.5); 
}

/* scrollpane sidebar - דריסה של בקובץ עיצוב הקיים של הפלאגין*/
#project .jspVerticalBar{
	background:none;	
}
#project .jspTrack{
	background:url(style/images/scroll_strip.png) no-repeat top right;	
}
#project .jspDrag{
	background:url(style/images/scroll_btn.png) no-repeat top right;
	height:30px;	
}
#project .jspDrag:hover{
	background:url(style/images/scroll_btn_h.png) no-repeat top right;	
}
#project .jspArrowUp{
	width:16px;
	height:20px;
	background:url(style/images/up_arrow.png) no-repeat top right;
}	
#project .jspArrowUp:hover{
	background:url(style/images/up_arrow_h.png) no-repeat top right;
}
#project .jspArrowDown{
	width:16px;
	height:20px;
	background:url(style/images/down_arrow.png) no-repeat top right;	
}
#project .jspArrowDown:hover{
	background:url(style/images/down_arrow_h.png) no-repeat top right;	
}
</style>



 
 
 
  <script>
$(document).ready(function() {
   
   $('#project').jScrollPane({
	   showArrows:true, 
	   scrollbarWidth: 10, 
	   verticalDragMaxHeight: 30,
	   verticalDragMinHeight: 30,
	   arrowSize: 10
	   });
  
  var myObject = eval(<?php echo  $st=json_encode($arr_pro); ?>); 
     var v= new Array();
	 for(var i in myObject)
		{    var x=myObject[i]['project_name'];
   			
			  v.push(x);
		}		
		
	  $("#find_project").autocomplete({
			source: v,
			 maxHeight:400,
             width:300,
			position:{my:"right top",at:"right bottom",collision:"none"},
			appendTo: "#search_autocomplete"

		});
		$('#find_bnt').click(function(){
			 if($('#find_project').val()==""){ alert('הכנס שם של פרוייקט');}
			 else {show_project_ajax_find($('#find_project').val(),$('#hid_session').val());
			 }
			
		});
		$('#find_project').bind('keypress', function(a) {
        if(a.which==13)
		{
			 if($('#find_project').val()==""){ alert('הכנס שם של פרוייקט');}
			 else {show_project_ajax_find($('#find_project').val(),$('#hid_session').val())};
		  
		}
    });
   
});
</script>
<script>
 function show_project(id)
		{ 
		  	show_project_ajax(id,$('#hid_session').val());
			//get_new_task();
			$('#hid_id_project').val(id);
			
		}
</script>